var React = require('react');
var AppComponent=require('./app.jsx');
var LoginComponent=require('./login.jsx');

var Router = React.createClass({
	getInitialState: function() {
		return {
		  pageid:'login',
		  uid:0,
		  pages:['login','todo']
		};
	},
	changeRouter:function(pid,uid){
		this.setState({
			pageid:pid,
			uid:uid
		})
	},
  	render: function () {
  		var pageComponent=<LoginComponent />;
  		switch(this.state.pageid)
  		{
  			case "login":
  				pageComponent=<LoginComponent changeRouter={this.changeRouter} />;
  				break;
  			case "todo":
  				pageComponent=<AppComponent uid={this.state.uid} />;
  				break;
  		};  		
	    return (
	      <div>
	      	{pageComponent}
	      </div>
	    );
	  }
});

module.exports = Router;